import Vue from "vue";

import Cookies from "js-cookie";

import "normalize.css/normalize.css"; // a modern alternative to CSS resets

import Element from "element-ui";
import "./styles/element-variables.scss";

import "@/styles/index.scss"; // global css

import App from "./App";
import store from "./store";
import router from "./router";
import kTag from "./components/adminTag.vue";

import "./icons"; // icon
import "./permission"; // permission control
import "./utils/error-log";
import * as filters from "./filters"; // global filters
import VueCoreVideoPlayer from "vue-core-video-player"
import VueQuillEditor from "vue-quill-editor"
import "quill/dist/quill.core.css"
import "quill/dist/quill.snow.css"
import "quill/dist/quill.bubble.css"
import echarts from "echarts"
import permission from "@/directive/permission/index"


Vue.use(permission)
Vue.prototype.$echarts = echarts
Date.prototype.format = function(fmt) {
    let o = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "H+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        S: this.getMilliseconds()
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(
            RegExp.$1,
            (this.getFullYear() + "").substr(4 - RegExp.$1.length)
        );
    }
    for (let k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
            fmt = fmt.replace(
                RegExp.$1,
                // @ts-ignore
                RegExp.$1.length === 1
                    ? o[k]
                    : ("00" + o[k]).substr(("" + o[k]).length)
            );
        }
    }
    return fmt;
};
Vue.use(VueCoreVideoPlayer)
Vue.use(VueQuillEditor)

Vue.use(Element, {
    size: Cookies.get("size") || "medium"
});

// register global utility filters
Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key]);
});

Vue.component("k-tag", kTag)
Vue.config.productionTip = false;
Vue.prototype.$EventBus = new Vue()
new Vue({
    el: "#app",
    router,
    store,
    render: h => h(App)
});
